package cn.jdy.plugins.admin.util;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import cn.jdy.authority.entity.UserRole;
import cn.jdy.authority.service.UserRoleService;
import cn.jdy.authority.service.UserService;
import cn.jdy.common.ctrl.BaseCtrl;
import cn.jdy.platform.service.ConfService;
import cn.jdy.plugins.entity.Live;
import cn.jdy.plugins.service.AdvertisingService;
import cn.jdy.plugins.service.ChatService;
import cn.jdy.plugins.service.LabelService;
import cn.jdy.plugins.service.LineService;
import cn.jdy.plugins.service.LiveService;
import cn.jdy.plugins.service.RedPacketReceiveService;
import cn.jdy.plugins.service.RelatedVideoService;
import cn.jdy.plugins.service.VisitLogService;








/**
 * @title 权限控制
 * @author jga
 */
@Controller
public class PowerUtil extends BaseCtrl {
	@Autowired
	private LineService lineService;
	@Autowired
	private RelatedVideoService relatedVideoService;
	@Autowired
	private RedPacketReceiveService redPacketReceiveService;
	@Autowired
	private UserRoleService userRoleService;
	@Autowired
	private UserService userService;
	@Autowired
	private LiveService liveService;
	@Autowired
	private ChatService chatService;
	@Autowired
	private ConfService confService;
	@Autowired
	private LabelService labelService;
	@Autowired
	private AdvertisingService advertisingService;
	@Autowired
	private VisitLogService visitLogService;


	// 默认列表路径

	/**
	 * 获取该机构下面的直播间
	 * 
	 * @return
	 */
	public  List<Live> organlist(String  userid) {
		List<UserRole> list = userRoleService.find("userid", userid);
		int roleid = 0;
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).getRoleid()
					.equals("4028b3044de1a396014de1ba2b2e0000")
					|| list.get(i).getRoleid()
							.equals("ff8080814db89f0a014db8d169290000")) {
				roleid = 1;
			}
		}
		if(roleid==0){
			String Organid=userService.findOne("userid",userid).getOrganid();
			return liveService.find("appid",Organid);
		}else{
			return liveService.findAll();
		}


	}

	
}
